﻿using System.Collections.Generic;
using System.Linq;
using Labthink.PCSoft.UniversalHost4.Model;

namespace Labthink.PCSoft.UniversalHost4.Instrument.Model
{
    public abstract class BaseParam
    {
        /// <summary>
        /// 试验类型
        /// 10033
        /// </summary>
        public Param TestType { get; set; }

        /// <summary>
        /// 试验名称
        /// 10069
        /// </summary>
        public Param TestName { get; set; }

        /// <summary>
        /// 试样名称
        /// 10070
        /// </summary>
        public Param SpecimenName { get; set; }

        /// <summary>
        /// 试样材料
        /// 10071
        /// </summary>
        public Param SpecimenMaterial { get; set; }

        /// <summary>
        /// 试样编号
        /// 10072
        /// </summary>
        public Param SpecimenId { get; set; }

        /// <summary>
        /// 操作员
        /// 10073
        /// </summary>
        public Param OpName { get; set; }

        /// <summary>
        /// 测试日期
        /// 10074
        /// </summary>
        public Param TestDate { get; set; }

        /// <summary>
        /// 测试时间
        /// 10075
        /// </summary>
        public Param TestTime { get; set; }

        /// <summary>
        /// 实验室温度
        /// 10076
        /// </summary>
        public Param Temperature { get; set; }

        /// <summary>
        /// 实验室湿度
        /// 10077
        /// </summary>
        public Param Humidity { get; set; }

        /// <summary>
        /// 试验标椎
        /// 10078
        /// </summary>
        public Param Standard { get; set; }

        /// <summary>
        /// 检方名称
        /// 10079
        /// </summary>
        public Param InspOrga { get; set; }

        /// <summary>
        /// 试样厂商
        /// 10080
        /// </summary>
        public Param Manufacturer { get; set; }

        /// <summary>
        /// 试样批次
        /// 10081
        /// </summary>
        public Param SpecimenBatch { get; set; }

        public abstract BaseParam Clone();

        /// <summary>
        /// 展开到具体参数
        /// </summary>
        /// <param name="parasList"></param>
        public abstract void FillFrom(IEnumerable<Param> parasList);
    }

    /// <summary>
    /// 默认参数
    /// </summary>
    public class TestType1 : BaseParam
    {
        /// <summary>
        /// 试验模式
        /// 1060
        /// </summary>
        //public Param SampleInfo { get; set; }

        /// <summary>
        /// 工位，即件数
        /// 1050
        /// </summary>
        //public Param SampleCount { get; set; }
        public override BaseParam Clone()
        {
            return new TestType1
            {
                TestType = (Param)TestType.Clone(),
                TestName = (Param)TestName.Clone(),
                SpecimenName = (Param)SpecimenName.Clone(),
                SpecimenMaterial = (Param)SpecimenMaterial.Clone(),
                SpecimenId = (Param)SpecimenId.Clone(),
                OpName = (Param)OpName.Clone(),
                TestDate = (Param)TestDate.Clone(),
                TestTime = (Param)TestTime.Clone(),
                Temperature = (Param)Temperature.Clone(),
                Humidity = (Param)Humidity.Clone(),
                Standard = (Param)Standard.Clone(),
                InspOrga = (Param)InspOrga.Clone(),
                Manufacturer = (Param)Manufacturer.Clone(),
                SpecimenBatch = (Param)SpecimenBatch.Clone(),
                //SampleInfo = (Param)SampleInfo.Clone(),
                //SampleCount = (Param)SampleCount.Clone(),
            };
        }

        public override void FillFrom(IEnumerable<Param> parasList)
        {
            List<Param> paras = parasList.ToList();

            TestName = paras.Single(d => d.DataNo == 10069);
            SpecimenName = paras.Single(d => d.DataNo == 10070);
            SpecimenMaterial = paras.Single(d => d.DataNo == 10071);
            SpecimenId = paras.Single(d => d.DataNo == 10072);
            Temperature = paras.Single(d => d.DataNo == 10076);
            Humidity = paras.Single(d => d.DataNo == 10077);
            Standard = paras.Single(d => d.DataNo == 10078);
            InspOrga = paras.Single(d => d.DataNo == 10079);
            Manufacturer = paras.Single(d => d.DataNo == 10080);
            SpecimenBatch = paras.Single(d => d.DataNo == 10081);
            //SampleCount = paras.Single(d => d.DataNo == 1050);
            //SampleInfo = paras.Single(d => d.DataNo == 1060);
            OpName = new Param { DataNo = 10073, DataType = DataType.String };
        }
    }

    public class TestType2 : BaseParam
    {
        public override BaseParam Clone()
        {
            return new TestType2();
        }

        public override void FillFrom(IEnumerable<Param> parasList)
        {

        }
    }
}
